from backtester.trade_back_tester import BackTester
from data.read_data import get_data_by_pickle, get_data_for_model
from data.time_data import TimeData
from strategy.greedy_strategy import GreedyStrategy
from strategy.gru_strategy import GRUStrategy
from strategy.concare_strategy import ConCareStrategy
from utils.date_util import diagnostics
import numpy as np

from view import Draw

if __name__ == '__main__':
    back_tester = BackTester(start_date="2010-01-05", end_date="2010-02-06",
                             trade_strategy=GreedyStrategy(3, 2, 3, 1000))
    # back_tester = BackTester(start_date="2010-01-30", end_date="2010-03-07", 
    #                          trade_strategy=GRUStrategy(3, 2, 3, 1000, './model/checkpoints/GRU/GRU_best_model.pt'))
    # back_tester = BackTester(start_date="2010-01-30", end_date="2010-03-07", 
    #                          trade_strategy=ConCareStrategy(3, 2, 3, 1000, './model/checkpoints/ConCare/ConCare_best_model.pt'))

    back_tester.execute_trade()

    cash = back_tester.get_cash_array()
    capital = back_tester.get_capital_array()
    stock = back_tester.get_stock_array()
    profits = back_tester.get_profit_array()
    Draw().draw_plot(cash, 'cash')
    Draw().draw_plot(capital, 'capital')
    Draw().draw_plot(profits, 'profits')

    print('-'*100)
    print(stock)
    print('-'*100)
    print(back_tester.get_profit_array())
    print('-'*100)
    print(diagnostics(np.array(list(profits.values())))/1000)
    
    
    




